<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../Public/sys/style/bootstrap.min.css?_v={$Think.config.version}" type='text/css' />
    <link rel="stylesheet" href="../Public/sys/style/bootstrap-responsive.min.css?_v={$Think.config.version}" type='text/css' />
    <link rel="stylesheet" href="../Public/sys/style/glDatePicker.default.css?_v={$Think.config.version}" type='text/css' />
    <link rel="stylesheet" href="../Public/sys/style/select2.css?_v={$Think.config.version}" type='text/css' />
    <link rel="stylesheet" href="../Public/sys/style/select2-bootstrap.css?_v={$Think.config.version}" type='text/css' />
    <link rel="stylesheet" href="../Public/sys/font-awesome/css/font-awesome.css?_v={$Think.config.version}" type='text/css' />
    <link rel="stylesheet" href='../Public/css/adam-base.css?_v={$Think.config.version}' type='text/css'>
    <link rel="stylesheet" href='../Public/css/adam-style.css?_v={$Think.config.version}' type='text/css'>
    <link rel="stylesheet" href='../Public/css/contextMenu.css?_v={$Think.config.version}' type='text/css'>
    <style>

        .ad-doc-left{ width: 300px; box-shadow:2px 0 5px rgba(0, 0, 0, 0.1); position: absolute; left : 0; top : 0 ; bottom :0 ; z-index: 10; overflow: auto; }

        .ad-doc-right{ height: 100%; position: absolute; left: 300px; right: 0; }

        .ad-doc-left .ad-doc-dl>dt { color: #353535; position: relative; height: 40px; font-size: 13px; line-height: 40px; background: #FFFCFC; padding: 0 5px 0 20px; border-bottom: 1px solid #eaeaea; }

        .ad-doc-left .ad-doc-dl.active>dt{ background: rgb(236, 109, 75); color: #fff; border-bottom: 0;}
        .ad-doc-left .ad-doc-dl>dt>i { font-size: 12px; float: right; height: 40px; line-height: 40px; }
        .ad-doc-left .ad-doc-dl>dd { cursor: pointer; color: #fff; height: 35px; line-height: 35px; -moz-transition: all 0.26s ease-out 0s; transition: all 0.26s ease-out 0s; }

        .ad-doc-left .ad-doc-dl>dd>a{padding-left: 35px;  text-decoration: none;display: block;  color: #333; }

        .ad-doc-left .ad-doc-dl>dd:hover,
        .ad-doc-left .ad-doc-dl>dd.active{ background: #FCD6CC;padding-left: 7px ; border-bottom: 0; }
        .ad-doc-left .ad-doc-dl>dd{overflow: hidden; height: 0;}
        .ad-doc-left .ad-doc-dl.active dd{  height: 35px; }
        .ad-doc-left .ad-doc-dl.active dd:last-child{ border-bottom: 1px solid #eee;}
        .ad-doc-right iframe{ width: 100%; height: 100%; border: 0; }
        .ad-doc-dl{ margin-bottom: 0; }
        .ad-doc-dl dt{}
        .ad-doc-dl dt i{ margin-right: 10px; }
        .cliceBtn{width: 30px;height: 20px;color:#1D1D1D;float: right;}
        .cliceBtn span{position: absolute;right: 0px;}
        .remove-box{ width: 100%;height: 100%;text-align: center;}
        .move-box-list{width: 100%;height: 55%;line-height: 70px;}
        .move-box-list input,select{width: 40%;height: 40px;}
        .move-box-list input{margin-left: 20px;}
        .move-box-list span{width: 20%;height: 50px; margin-left: 10px;margin-right: 10px;}
        .move-box-list .intocate option{height: 30px;}
        .move-box-action{width: 100%;height: 45%;border-top: 1px solid #ddd}
        .move-box-action .btnlist{width: 50%;height: 100%;float: right;font-size: 16px;}
        .move-box-action input[type=button]{width: 80px;height: 40px; margin: 15px;}
        .move-box-action .quedingbtn{margin-right: 20px;background: #0acb83;}
        .move-box-action .canclebtn{background: #e86348;}
    </style>
    <script src="../Public/js/jquery-1.7.2.min.js?_v={$Think.config.version}"></script>
    <script src="../Public/js/contestMenu.js?_v={$Think.config.version}"></script>
</head>

<body>
<div class="ad-doc-left">
    <volist name="elist" id="eid">
        <dl class="ad-doc-dl active">
			
				<dt> {$eid.title} <i class=" animate-topAndBottom fa fa-caret-down"></i> </dt>
				<volist name="eid.data" id="dv">
					<dd>
                        <a href="{:U('Market/details',array('id'=>$dv['id']))}" target="detail-frame">
						<i class="fa fa-angle-double-right"></i>
						<span class="ico_{$dv.ui.icon}"></span>
                            <div class="cliceBtn"><span class="context-menu-one btn btn-neutral" data-id="{$dv['id']}">操作</span></div>
						<b>{$dv.ui.title}</b></a>
					</dd>
				</volist>
		
        </dl>
    </volist>
</div>
<div class="ad-doc-right">
    <iframe name="detail-frame" id="detail-frame"></iframe>
</div>
<div id="ad-js-loading" class="ad-doc-loading"><div><span>数据加载中 ...</span></div></div>
</body>
<input type="hidden" id="version" value="{$Think.config.version}" />
<script>



    // 公共模块
    var pubClassPath = "../Public/sys/class/";
    var pubLibPath = "../Public/sys/lib/";
    var classPath = "../Public/app/common/";
    var OPTIONS = {
        lang: "javascript",
        type: "text/javascript",
        charSet: "utf-8",
        version : document.getElementById("version").value || null,
        core: [
            [
                pubClassPath + "jquery.min"
            ]
        ],
        module: [
            [
                pubClassPath + "bootstrap.min",
                classPath + "control.class",
                pubLibPath + "handle.class",
                classPath + "model.class"
            ],
            [
                //pubClassPath + "jquery.glDatePicker",
                pubClassPath + "jquery.tmpl.min",
                pubClassPath + "jquery.toastr",
                pubClassPath + "select2.min"
            ],
            [
                pubLibPath + "handle.ext.class",
                classPath + "view.class"
            ]
        ],
        index: [
            [
                classPath + "app"
            ]
        ]
    };
</script>
<script src="../Public/sys/lib/public.js?_v={$Think.config.version}"></script>
<script src="../Public/sys/lib/public_run.js?_v={$Think.config.version}"></script>
<script src="../Public/js/layer/layer.js?_v={$Think.config.version}"></script>
<script>
    var id = 0;
    $('.context-menu-one').mousedown(function(e){
        if(3 == e.which){
            id = $(this).attr('data-id');
        }

    })

    $(".context-menu-one").contextMenu({
        menu: [{
            text: "重命名",
            callback: function() {
                    reEggName(id);
                }
            },
            {
                text: "移动",
                callback: function() {
                    removeEgg(id);
                }
            },
            {
                text: "删除",
                callback: function() {
                    deleteEgg(id);
                }
            }
        ]
    });
    /**
     * 重命名
     */
    function reEggName(id) {
        layer.prompt({title:'重命名'},function(val, index){
            $.ajax({
                url:"{:U('Market/eggrename')}",
                data:{'id':id,'rename':val},
                type:"POST",
                dataType:"json",
                success:function(data){
                    layer.msg(data.msg);
                    setTimeout(function () {
                        window.location.reload();
                    },1500);
                },
                error:function(data){
                    layer.msg(data.msg);
                }
            });
            layer.close(index);
        });
    }
    /**
     * 移动
     */
    function removeEgg(id) {
        //获取类型
        $.ajax({
            url:"{:U('Market/geteggparentlist')}",
            data:{'id':id},
            type:"GET",
            dataType:"json",
            success:function(data){
                var oldtype = data.title;
                var typelist = data.typelist;
                var option = '';
                for(var i=0;i<typelist.length;i++){
                    option += '<option value="'+typelist[i].id+'">'+typelist[i].title+'</option>';
                }

                var html = '<div class="remove-box">' +
                                '<div class="move-box-list">' +
                                    '<input type="text" value="'+oldtype+'" class="disableinput" disabled><span>移动到</span>'+
                                        '<select class="intocate">' +
                                        option+
                                        '</select>'+
                                    '</div>'+
                                    '<div class="move-box-action">' +
                                    '<div class="btnlist">'+
                                        '<input type="button" class="quedingbtn" value="确定">'+
                                        '<input type="button" class="canclebtn" value="取消">'+
                                    '</div>'+
                                '</div>'+
                            '</div>';
                layer.open({
                    title:'移动类型',
                    type: 1,
                    skin: 'layui-layer-demo', //样式类名
                    closeBtn: 0, //不显示关闭按钮
                    anim: 2,
                    area:['500px','200px'],
                    shadeClose: true, //开启遮罩关闭
                    content: html
                });


                $('.canclebtn').click(function () {
                    layer.closeAll();
                });

                $('.quedingbtn').click(function () {
                    var newtypeid = $('.intocate').val();
                    $.ajax({
                        url:"{:U('Market/removegg')}",
                        data:{'id':id,'newtypeid':newtypeid},
                        type:"GET",
                        dataType:"json",
                        success:function(data){
                            layer.msg(data.msg);
                            setTimeout(function () {
                                window.location.reload();
                            },1500);
                        },
                        error:function(data){
                            layer.msg(data.msg);
                        }
                    });
                });
            },
            error:function(data){
                layer.msg(data.msg);
            }
        });

    }

    /**
     * 删除
     * @param id int 操作id
     */
    function deleteEgg(id) {
        layer.confirm('确定删除吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                url:"{:U('Market/deleteegg')}",
                data:{'id':id},
                type:"GET",
                dataType:"json",
                success:function(data){
                    layer.msg(data.msg);
                    setTimeout(function () {
                        window.location.reload();
                    },1500);
                },
                error:function(data){
                    layer.msg(data.msg);
                }
            });
        }, function(){

        });
    }
</script>
</html>
